let { User,Message,Comment } = require('../models');
const auth = require('../utils/auth');
// 首页
let index_fn = async (ctx, next) => {
    ctx.render('index.html');
}
//登录
let login_fn=async (ctx,next)=>{
    ctx.render('login.html')
}
//注册
let register=async (ctx,next)=>{
    ctx.render('register.html')
}
//未完成页面
let unfinished=async (ctx,next)=>{
    ctx.render('unfinished.html')
}
//创建问卷
let chuangjian=async (ctx,next)=>{
    ctx.render('chuangjian.html')
}
//创建问卷
let Administrator=async (ctx,next)=>{
    ctx.render('Administrator.html')
}
let userpdd=async (ctx,next)=>{
    ctx.render('userpdd.html')
}
let userpd=async(ctx,next)=>{
    let username=ctx.request.body.username || "";
    let password=ctx.request.body.password || "";
    if(username==='admin' && password==='123'){
        ctx.response.redirect('/Administrator');
    }else{
        ctx.response.body = '<h1>账号或密码错误</h1>';
    }
}

module.exports={
    '/':['get',auth,login_fn],
    '/index':['get',auth,index_fn],
    '/register':['get',register],
    '/chuangjian':['get',chuangjian],
    '/unfinished':['get',unfinished],
    '/Administrator':['get',Administrator],
    '/userpdd':['get',userpdd],
    '/userpd':['post',userpd],
}